/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package heuristics;

import java.io.File;
import java.util.ArrayList;

/**
 *
 * @author 3mara
 */
public class RealizableSets {

    public static void main(String[] args) {
        int numpers[] = {10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100};
        int mindist[] = {5, 7, 8, 12, 12, 17, 20, 24, 30, 34, 37, 40};
//        int numpers[] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
//        int mindist[] = {5, 8, 12, 17, 20, 24, 30, 34, 37, 40};
        double avgs[] = new double[numpers.length];
        double stddvs[] = new double[numpers.length];
        double stabs[] = new double[numpers.length];

        for (int k = 0; k < numpers.length; k++) {
            int numPersons = numpers[k];
            int minDistance = mindist[k];
            File folder = new File("assets/Scenes/maps_" + numPersons + "_" + minDistance);
            File[] listOfFiles = folder.listFiles();
            listOfFiles = folder.listFiles();
//            HeuristicSimulation heu = null;
            int NUM_TO_RUN = 1;
            int numAlgos = 1; // set to number of used algorithms
            ArrayList<Double>[] thetaChanges = new ArrayList[numAlgos];
            double totalAvg[] = new double[numAlgos];
            double percentCovg[] = new double[numAlgos];
            double stdev[] = new double[numAlgos];
            int min[] = new int[numAlgos];
            int max[] = new int[numAlgos];
            double cvg[][];
            double avgStability[] = new double[numAlgos];
            double avg = 0;
            double avgZoom = 0;
            double avgPan = 0;
            double avgTime = 0;
            double camPersonAvg = 0;
            double k_angleAvg = 0;
            for (int mapIndex = 1; mapIndex < listOfFiles.length; mapIndex++) {
                AngularSweep as = new AngularSweep(listOfFiles[mapIndex].getAbsolutePath());
                as.screenRatio = new double[as.number_of_men];
                as.cameraPperson = new double[as.number_of_men];
                long start = System.currentTimeMillis();
                int[] assignment = as.reassign();
                long end = System.currentTimeMillis();
//                double temp = 0;
//                double temp2 = 0;
                avgTime += end - start;
//                int[] zoomsAss = as.getZooms();
//                as.saveImage(mapIndex, assignment, 0, zoomsAss);
//                camPersonAvg += cameraPerson(as.cameraPperson);
//                double c = as.computeCoverage();
//                avg += c / as.number_of_men;
//                for (int i = 0; i < as.number_of_men; i++) {
//                    temp += as.screenRatio[i];
//                }
//                for (int i = 0; i < as.number_of_cameras; i++) {
//                    temp2 += as.deltaPan[i];
//                }
//                temp2 /= as.number_of_cameras;
//                avgPan += temp2;
//                temp /= as.number_of_men;
//                avgZoom += temp;
//                System.out.println("DONE");
//                System.out.print(c + "\n");
//                k_angleAvg += k_angle_camera(as);
            }
//            System.out.println(avg / listOfFiles.length + "\t");
//            System.out.println(avgZoom / listOfFiles.length + "\t");
//            System.out.println(avgPan / listOfFiles.length + "\t");
            System.out.println(avgTime / listOfFiles.length);
//            System.out.println(camPersonAvg / listOfFiles.length + "\t");
//            System.out.println(k_angleAvg / listOfFiles.length);
//            System.out.println("=================");
        }
    }

    public static double k_angle_camera(AngularSweep as) {
        double result = 0;
        for (int i = 0; i < as.diffCamera.length; i++) {
            for (int j = 0; j < as.diffCamera[i].length; j++) {
                result += as.diffCamera[i][j];
            }
        }
        result /= as.diffCamera[0].length;
        result /= as.number_of_men;
        return result;
    }

    public static double cameraPerson(double[] cameraPperson) {
        double result = 0;

        for (int i = 0; i < cameraPperson.length; i++) {
            result += cameraPperson[i];
        }
        return result / cameraPperson.length;
    }
}
